package com.qian.service.ddj.dao;

import com.qian.service.ddj.entity.DdjUserBusiness;
import com.yaowk.service.common.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserBusinessRepository extends BaseRepository<DdjUserBusiness, Integer> {

    List<DdjUserBusiness> findByUserIdOrderByVersion(Integer userId);

    List<DdjUserBusiness> findByBusinessId(Integer id);

    @Query("update DdjUserBusiness d set d.version = 0 where d.userId = ?1")
    @Modifying
    void setVersionByUserId(Integer id);
}
